package org.iodocs.mojo;

/**
 * User: Anjana D. Kulasinghe
 * Date: 10/3/13
 */

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;


/**
 * @goal generate
 * @phase install
 */
public class GenerateIoDocsMojo extends AbstractMojo {

    /**
     * @parameter default-value="Default Name"
     */
    private String docName;

    /**
     * @parameter default-value="Default Title"
     */
    private String docTitle;

    /**
     * @parameter default-value="Default Description"
     */
    private String docDescription;

    /**
     * @parameter default-value="1.0"
     */
    private String docVersion;

    /**
     * @parameter default-value="http://api.com/"
     */
    private String docBasePath;

    /**
     * @parameter default-value="$HOME/class.list"
     */
    private String docClassListPath;

    /**
     * @parameter default-value="OutPut.txt"
     */
    private String docOutputFile = "OutPut.txt";

    public void execute() throws MojoExecutionException, MojoFailureException {

        System.out.println(docName);
        System.out.println(docTitle);
        System.out.println(docDescription);
        System.out.println(docVersion);
        System.out.println(docBasePath);
        System.out.println(docClassListPath);
        System.out.println(docOutputFile);
        System.out.println("****************");

        // Generating IO Docs
        IoDocGenerator ioDocGenerator = new IoDocGenerator();
        Class<?>[] endpoints = ioDocGenerator.getClassList(docClassListPath);
        System.out.println(ioDocGenerator.generateIoDoc(docName, docTitle, docDescription, docVersion, docBasePath, endpoints, docOutputFile));
    }

}